﻿@model Inscriptionem.Models.Menu.Views.SectionsViewModel
           
@{
    string menuItemClass = "page_item";
    string selectedMenuItemClass = "current_page_item";

    bool isSectionSelected = false;
}

<ul class="navis navi-primary">
    @foreach (var section in Model.Sections)
    {
        bool select = !isSectionSelected &&
                        ((string.IsNullOrWhiteSpace(Model.Section)) || 
                        (!string.IsNullOrWhiteSpace(Model.Section) &&
                        Model.Section.ToLower() == section.Name.ToLower() || Model.Section.ToLower() == Model.Sections.First(m => m.IsDefault).Name.ToLower()));
                    
        if(select)
        {
            isSectionSelected = true;
        }
        
    <text>
    <li class="@(select ? selectedMenuItemClass : menuItemClass)">
        <a href="/@Model.Language/@(section.Name)/">@(section.LocalizedName)</a>
    </li>
    </text>
    }

    <li class="@(Model.Section == "Contact" ? selectedMenuItemClass : menuItemClass)"><a href="/@Model.Language/Contact/">Обратная связь</a></li>
</ul>